<?php
class DictionaryObjModel extends Model {
	/**
	 * Get dictionary by id
	 *
	 * @param integer $id
	 * @return array
	 */
	public function getDictById($id) {
		$queryString = sprintf("
			SELECT 
				*
			FROM
				`dictionary`
			WHERE
				`dictionary`.`id` = %d
		", $id 
		);
		$result = $this->_sqlInstance->query($queryString);
		return $result;
	}
	
	/**
	 * Save dictionary
	 *
	 * @param Dictionary $item
	 * @return mysqli_result
	 */
	public function save(Dictionary $dict) {
		$queryString = sprintf("
			INSERT INTO
				`dictionary`(`name`, `status`)
			VALUES
				('%s', '%s');
		", $dict->name, $dict->getStatus());
		$this->_sqlInstance->query($queryString);
	}

    public function getByName($dictName) {
        $queryString = sprintf("
			SELECT
				*
			FROM
				`dictionary`
			WHERE
				`dictionary`.`name` = '%s'
		", $dictName
		);
		$result = $this->_sqlInstance->query($queryString);
		return $result;
    }
}